package org.example.dining_philosopher_problem;

public class dining_philosopher{

    public static void main(String[] args) {
        //哲学家进餐问题（并发编程）

        //五根筷子
        chopsticks c1 = new chopsticks(1);
        chopsticks c2 = new chopsticks(2);
        chopsticks c3 = new chopsticks(3);
        chopsticks c4 = new chopsticks(4);
        chopsticks c5 = new chopsticks(5);

        //五个哲学家
        philosopher p1 = new philosopher(c1, c2, 1);
        philosopher p2 = new philosopher(c2, c3, 2);
        philosopher p3 = new philosopher(c3, c4, 3);
        philosopher p4 = new philosopher(c4, c5, 4);
        philosopher p5 = new philosopher(c5, c1, 5);

        //开始进餐
        p1.start();
        p2.start();
        p3.start();
        p4.start();
        p5.start();

    }
}
